﻿#pragma once

#include "qlib/geo/path.h"

namespace qlib {
class QLIB_API FlyLine {
 public:
  FlyLine();
  ~FlyLine();

  using s_ptr = std::shared_ptr<FlyLine>;
  template <typename... Args>
  static s_ptr create(Args... args) {
    return std::make_shared<FlyLine>(args...);
  }
  // template <>
  static s_ptr create() {
    return std::make_shared<FlyLine>();
  }
  static s_ptr create(const FlyLine& value) { return std::make_shared<FlyLine>(value); }

  s_ptr copy() const;

  std::vector<Vec2d> get_points();
  Vec2d getPinPoint(const std::string& pin_name);
  Vec2dArray bounding_box();

  /**
   * @brief 变换标签
   *
   * @param[in] magnification 缩放倍率
   * @param[in] x_reflection  是否沿x轴镜像
   * @param[in] rotation      旋转角度
   * @param[in] origin        变换原点
   */
  void transform(double magnification, bool x_reflection, double rotation, const Vec2d origin);
  void rotate(double angle, Vec2d center);
  void translate(double dx, double dy);
  void mirror(qlib::Vec2d p0, qlib::Vec2d p1);

  std::shared_ptr<Path> m_flexpath;
  std::string pin_1, pin_2;

  uint32_t layer{0};
  uint32_t datatype{0};

  Vec2dArray lines;  // 渲染缓存

  Vec2dArray box;
  bool is_show = true;
};
}  // namespace qlib